package com.zzyl.controller.customer;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectPageQueryDto;
import com.zzyl.dto.OrderQueryDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.service.OrderService;
import com.zzyl.utils.ThreadLocalUtil;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "客户订单管理")
@RestController
@RequestMapping("/customer/orders")
@Slf4j
public class CustomOrderController {
    @Autowired
    NursingProjectService nursingProjectService;


    @ApiOperation("根据编号查询护理项目信息")
    @GetMapping("/project/{id}")
    public ResponseResult<NursingProjectVo> getbyProjectId(@PathVariable Long id) {
        log.info("根据id查询护理项目信息：{}", id);
        NursingProjectVo nursingProjectVo = nursingProjectService.read(id);

        return ResponseResult.success(nursingProjectVo);
    }

    @ApiOperation("分页查询护理项目列表")
    @GetMapping("/project/page")
    public ResponseResult<PageBean<NursingProjectVo>> getProjectPage(NursingProjectPageQueryDto pageQueryDto) {
        log.info("分页查询护理项目列表：{}", pageQueryDto);
        PageBean<NursingProjectVo> pageBean = nursingProjectService.findByPage(pageQueryDto);
        return ResponseResult.success(pageBean);
    }


    ///////////////////////////////////////////////////////////////////////////////

    @Autowired
    private OrderService orderService;

    @ApiOperation("分页查询订单")
    @GetMapping("/order/page")
    public ResponseResult<PageBean<OrderVo>> searchOrders(OrderQueryDto dto) {
        dto.setUserId(ThreadLocalUtil.get());
        PageBean<OrderVo> pageBean = orderService.searchOrders(dto);
        return ResponseResult.success(pageBean);
    }
}

